/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.teste;

import br.com.modelo.Editora;
import java.util.Scanner;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author egberto
 */
public class InsereEditoraComJPA {
    
    public static void main(String args[]){
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("default");
        EntityManager em = emf.createEntityManager();
        
        Editora editora = new Editora();
        
        Scanner entrada = new Scanner(System.in);
        
        System.out.println("Digite o nome da editora: ");
        editora.setNome(entrada.nextLine());
        
        System.out.println("Digite o email da editora: ");
        editora.setEmail(entrada.nextLine());
        
        em.getTransaction().begin();
        em.persist(editora);
        em.getTransaction().commit();
        
        emf.close();
        
    }
    
}
